% /*******************************************************************************
%  * Variable Correction Method : constant calculation
%  * *****************************************************************************
%  * Compute Variable(data-dependent) Correction Constant. For more detail, 
%  * see @text(Stine04 p74). In summary, PP(m+n-r-k-1) (leftmost of SLP_minor,IC)
%  * is used to estimate errors->add PP(m+n-r-k-1) bits to PP(m+n-r-k). 
%  * 
%  * @param a     Multiplicand
%  * @param b     Multiplier
%  * @param m     Multiplicand Width
%  * @param n     Multiplier Width
%  * @param r     Product Width
%  * @param k     Extra bits to keep
%  * @return      VC constant
%  */
function cor_tot = vcm_const(a,b,m,n,r,k)
j = m+n-r-k-1;
if (n < (r + k))
    b_start = n;
else
    b_start = r + k - 1;
end
one_count = 0;
a_int = uint32(((a*(2^m))));
b_int = uint32((b*(2^n)));
for q = n - b_start + 1 : n-1
    if(bitand(uint32(2^q),b_int) && bitand(uint32(2^(j-q)),a_int))
        one_count = one_count + 1;
    end
end
cor_tot = one_count * 2^(-r-k);
end